package cn.wl.hrm.feign.client;

import cn.wl.hrm.feign.fallback.RedisFeignClientFallbackFactory;
import cn.wl.hrm.util.AjaxResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(value = "cache-server",fallbackFactory = RedisFeignClientFallbackFactory.class)
public interface RedisFeignClient {

    //@RequestParam("key"):从请求参数中获取名字为key的数据
    @RequestMapping(value = "/redis/set",method = RequestMethod.POST)
    AjaxResult set(@RequestParam("key") String key, @RequestParam("value") String value);

    @RequestMapping(value = "/redis/setex",method = RequestMethod.POST)
    AjaxResult setex(@RequestParam("key") String key,@RequestParam("seconds") int seconds, @RequestParam("value") String value);

    //@PathVariable("key") :从 url中获取参数
    @RequestMapping(value = "/redis/get/{key}",method = RequestMethod.GET)
    AjaxResult get(@PathVariable("key") String key);
}
